
import React from "react"
import { ScrollView, View, Slot } from "@tarojs/components"
import { AtActivityIndicator } from 'taro-ui'
import styles from './index.module.scss';

const ScrollDmt  = (props) => {

  const { children, handleRefresh, isRefresh, handleLoadMore, isLoading } = props;



  return (
    <ScrollView
      className={styles.scrollContent}
      scrollY
      refresherEnabled
      refresherThreshold={40}
      refresherDefaultStyle='none' // 不使用默认样式
      refresherBackground='#fff'
      refresherTriggered={isRefresh}
      onRefresherRefresh={handleRefresh}
      lowerThreshold={40}
      onScrollToLower={handleLoadMore}
    >
      {/* 自定义加载动画 start*/}
      <Slot name='refresher'>
        <View  className={styles.refreshLoading}>
          <AtActivityIndicator content={!isRefresh ? '刷新中...' : '刷新完成'}></AtActivityIndicator>
        </View>
      </Slot>
      {/* 插槽内容 */}
      {children}
      {
        isLoading && <View className='refresh-loading'>
          <AtActivityIndicator content='加载中...'></AtActivityIndicator>
        </View>
      }
    </ScrollView>
  )
}

export default ScrollDmt

